import { defineConfig } from "vite";
import uni from "@dcloudio/vite-plugin-uni";
import { visualizer } from "rollup-plugin-visualizer";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    uni(),
	visualizer()
  ],
  css: {  
	preprocessorOptions: {  
	  scss: {  
		// 取消sass废弃API的报警
		silenceDeprecations: ['legacy-js-api', 'color-functions', 'import'],  
	  },  
	},  
  },
  server: {
    port: 5100,
    fs: {
        // Allow serving files from one level up to the project root
        allow: ['..']
    }
  },
  // H5构建配置，支持部署到宝塔面板的8080端口
  build: {
    outDir: 'dist/build/h5',
    assetsDir: 'static'
  },
  // 设置uni-app的H5相关配置
  uni: {
    h5: {
      // 配置H5的base路径，确保资源正确加载
      base: './',
      // 配置H5的路由模式
      router: {
        mode: 'hash'
      }
    }
  }
});